/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.dao.ibatis;

import model.dao.AsambleaDao;
import com.ibatis.sqlmap.client.SqlMapClient;
import model.bean.Asamblea;
import java.util.List;
import java.util.Map;
import model.common.ibatis.IbatisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

/**
 * @Archivo AsambleaDaoIbatis.java
 * @Fecha                @Autor   @Cambios
 * 21/01/2011 04:06:26 PM       moshiro
 */
@Repository
public class AsambleaDaoIbatis extends SqlMapClientDaoSupport implements AsambleaDao {

    @Autowired
    public AsambleaDaoIbatis(SqlMapClient arg) {
        setSqlMapClient(arg);
    }

    public Long agregarAsamblea(Asamblea asamblea) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(asamblea);
        return ((Long) getSqlMapClientTemplate().queryForObject("agregarAsamblea", parameterMap)).longValue();
    }

    public Integer modificarAsamblea(Asamblea asamblea) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(asamblea);
        return ((Integer) getSqlMapClientTemplate().update("modificarAsamblea", parameterMap));
    }

    public Integer eliminarAsamblea(Long codigo) throws DataAccessException {
        Asamblea asamblea = new Asamblea();
        asamblea.setCodigo(codigo);
        return ((Integer) getSqlMapClientTemplate().delete("eliminarAsamblea", asamblea));
    }

    public List<Asamblea> listarAsamblea(Asamblea asamblea) throws DataAccessException {
        Map parameterMap = IbatisUtils.processBean(asamblea);
        return getSqlMapClientTemplate().queryForList("listarAsamblea", parameterMap);
    }

}
